using UnityEngine;

namespace StarForce
{
    public class Ink : Entity
    {
        private float m_LocationY = 2f;

        private float m_HiddenTime = 3f;

        private float m_HiddenCurTime = 0;

        protected override void OnShow(object userData)
        {
            base.OnShow(userData);
            SetLocationY();
            CachedTransform.localScale = new Vector3(5,11,1);
            CachedTransform.GetComponent<SpriteRenderer>().sortingOrder = 2;
            m_HiddenCurTime = 0;
        }

        private void Update()
        {
            SetLocationY();
            if (m_HiddenCurTime<m_HiddenTime)
            {
                m_HiddenCurTime += Time.deltaTime;
            }
            else
            {
                m_HiddenCurTime = 0;
                GameEntry.Entity.HideEntity(this);
            }
        }

        private void SetLocationY()
        {
            CachedTransform.position = new Vector3(0, GameEntry.Camera.MainCamera.transform.position.y + 2f, 1);
        }
    }
}